﻿<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Agr.Questionnaire.Core" namespace="Agr.Questionnaire.Core.ViewModel.Qnnaire">
  <class name="QuestionnaireInList">
    <id type="int">
      <generator class="native"/>
    </id>
    <property name="AggregateRootId"/>
    <property name="Version"/>
    <property name="Name"/>
    <property name="NumberOfSections"/>
    <property name="NumberOfQuestions"/>
  </class>

  <class name="QuestionnaireDetail">
    <id type="int">
      <generator class="native"/>
    </id>
    <property name="AggregateRootId"/>
    <property name="Version"/>
    <property name="Name"/>

    <bag name="AnswerableQuestions" table="QuestionnaireDetail_AnswerableQuestionInList"
        order-by="SequenceNumber" fetch="join" cascade="all-delete-orphan">
      <key column="QuestionnaireId"  />
      <one-to-many class="QuestionnaireDetail_AnswerableQuestionInList"/>
    </bag>
  </class>

  <class name="QuestionnaireDetail_AnswerableQuestionInList">
    <id type="int">
      <generator class="native"/>
    </id>
    <property name="EntityNumber"/>
    <property name="SequenceNumber"/>
    <property name="QuestionType"/>
    <property name="Question"/>
    <property name="AnswerType"/>
    <property name="AnswerOptions"/>
  </class>

</hibernate-mapping>
